<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <div class="well form-inline margin-top-20""><a class="btn btn-default" href="{:url('Alsdk/DescribeUserDomains')}"><<返回域名列表</a>&nbsp;&nbsp;{$domain}
    <div style="float:right;" class="form-group">
    	回调地址：
    	<notempty name="Notify">{$Notify}
	    	<!-- <a class="btn btn-link btn-sm" href="{:url('Alsdk/UpdateLiveRecordNotifyConfig', array('domain'=>$domain))}">编辑</a> -->
	    	<!-- <a class="btn btn-link btn-sm" onclick="DeleteLiveRecordNotifyConfig('{$domain}')">删除</a> -->
            <else /> 未设置
	    	<a class="btn btn-link btn-sm" href="{:url('Alsdk/AddLiveRecordNotifyConfig', array('domain'=>$domain))}">添加</a>
        </notempty>
    </div>
    </div>
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">录制配置列表</a></li>
        <li><a href="{:url('Alsdk/AddLiveAppRecordConfig', array('domain'=>$domain))}">添加录制配置</a></li>
    </ul>
    <form class="js-ajax-form" action="" method="post">
        <div class="well form-inline margin-top-20">
        顺序:
        <select class="form-control" name="Order" style="width: 140px;">
            <option value='asc' <if condition="$search['Order'] eq 'asc'">selected="selected"</if>>顺序</option>
            <option value='desc' <if condition="$search['Order'] eq 'desc'">selected="selected"</if>>倒序</option>
        </select> &nbsp;&nbsp;
        AppName:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$search['keyword']|default=''}" placeholder="请输入AppName">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('Alsdk/DescribeLiveRecordConfig', array('domain'=>$domain))}">清空</a>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <notempty name="category">
                    <th width="50">{:lang('SORT')}</th>
                </notempty>
                <th>AppName</th>
                <th>StreamName</th>
                <th>OSS endpoint</th>
                <th>OSS 存储 bucket 名称</th>
                <th>存储信息</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <foreach name="info" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo->DomainName}" title="ID:{$vo->DomainName}">
                    </td>
                    <td>{$vo->AppName}</td>
                    <td>{$vo->StreamName}</td>
                    <td>{$vo->OssEndpoint}</td>
                    <td>{$vo->OssBucket}</td>
                    <td>
                    	<?php $RecordFormat = $vo->RecordFormatList->RecordFormat;?>
                    	<foreach name="RecordFormat" item="vs">
                    		<table class="table table-bordered table-list">
                    		<tr>
				                <td>周期</td>
				                <td>格式</td>
				                <td>文件位置</td>
				            </tr>
				            <tr>
				                <td>{$vs->CycleDuration}</td>
				                <td>{$vs->Format}</td>
				                <td>{$vs->OssObjectPrefix}</td>
				            </tr>
				        	</table>
                    	</foreach>
                    </td>
                    <td>{$vo->CreateTime}</td>
                    <td>
                        <a class="btn btn-danger btn-sm" style="margin:1px;" onclick="DeleteLiveAppRecordConfig('{$domain}', '{$vo->AppName}', '{$vo->StreamName}')">删除</a>
                    </td>
                </tr>
            </foreach>
            </tfoot>
        </table>
        <ul class="pagination">{$meetingList['page']|default=''}<li class="page item"><a class="page link" href="#">总数：{$count}条</a></li></ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
	// 删除回调地址
	function DeleteLiveRecordNotifyConfig(Domain)
	{
		var data = {
            DomainName:Domain,
        }
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: '确定删除回调地址？',
            cancelVal: '关闭',
            ok: function () {
               myAjax("{:url('Alsdk/DeleteLiveRecordNotifyConfig')}", data)
            }
        });
	}

    // 删除配置
    function DeleteLiveAppRecordConfig(Domain, AppName, StreamName)
    {
        var data = {
            DomainName:Domain,
            AppName:AppName,
            StreamName:StreamName,
        }
        art.dialog({
            id: 'warning',
            icon: 'warning',
            title: '提示',
            content: '确定删除此配置？',
            cancelVal: '关闭',
            ok: function () {
               myAjax("{:url('Alsdk/DeleteLiveAppRecordConfig')}", data)
            }
        });
    }

    // 执行提交
    function myAjax(url, data){
        $.ajax({
            url: url,
            dataType: 'json',
            data: data,
            type: "POST",
            success: function(data){
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (data.url) {
                                    window.location.href = data.url;//返回带跳转地址              
                                } else {
                                    //刷新当前页
                                    reloadPage(window);
                                }
                            }
                        }
                    }).show();
                } else if (data.code == '0') {
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            }
        }); 
    }

</script>
</body>
</html>